// Using jQuery with Other Libraries
try {
jQuery.noConflict();

// Roodo extensions Options
var BloggerExtOptions = {
    core_version: '0.1.2'
};

var BloggerExt = {};
jQuery.extend( BloggerExt, {
        extensions: [],

        register: function(flag, opts) {
            BloggerExt.extensions.push(flag);
            if(opts) { jQuery.extend(BloggerExtOptions, opts); }
        },

        process: function() {
            jQuery(document).ready( function(){
                var flag;
                while( flag = BloggerExt.extensions.pop() ) {
                    if(BloggerExtOptions[flag]) { try { BloggerExt[flag](); }catch(e){} }
                }
            });
        },

        registerAndProcess: function(flag, opts) {
            BloggerExt.register(flag,opts);
            BloggerExt.process();
        }
});


BloggerExt.getSideObjByTitle = function(title) {
    var sideTitleAndContent = [];
    jQuery('.sidetitle').each( function(i) {
            var objSideTitle = jQuery(this);
            var objSide = jQuery(this).next();
            objSideTitle.contains(title).each( function(){ sideTitleAndContent.push(objSideTitle); sideTitleAndContent.push(objSide); } );
    });
    return sideTitleAndContent;
};


// Register hide_sidebar_html_markup
BloggerExt.hide_sidebar_html_markup = function() {

    var hiddenSides = BloggerExt.getSideObjByTitle('##HIDEME##');
    for(var i=0; i<hiddenSides.length; i+=2) {
        var objTitle = hiddenSides[i];
        var objSide = hiddenSides[i+1];
        if (objTitle != 'undefined') objTitle.hide();
        if (objSide != 'undefined') objSide.hide();
    }

};
BloggerExt.register('hide_sidebar_html_markup', { hide_sidebar_html_markup: true} );



// Register sidebar_widget_expandable
BloggerExt.sidebar_widget_expandable = function() {

    // find containers to expandable.
    jQuery.each(BloggerExtOptions.sidebar_widget_expandable_ids, function(i) {
        // find widget container with class name
        var sideTitle = this;
        var sideObjs = BloggerExt.getSideObjByTitle(sideTitle);
        if (sideObjs.length >= 2) {
            var widgetId = "expandable_side_" + i;
            var titleObj = sideObjs[0];
            var contentObj = sideObjs[1];
            var animate_str = "";
            if(BloggerExtOptions.sidebar_widget_expandable_animate) {
                var animate_str = "'fast',";
            }else {
                var animate_str = ").each(";
            }
            var link = "<span class=\"sidebar-widget-expand\"><a onclick=\"jQuery('#"+widgetId+"_content').toggle("+animate_str
                      +"function(){ "
                      +"  jQuery(this).is(':hidden') ? "
                      +"  jQuery('#"+widgetId+"_title a:eq(0)').html(BloggerExtOptions.sidebar_widget_expan_title) : "
                      +"  jQuery('#"+widgetId+"_title a:eq(0)').html(BloggerExtOptions.sidebar_widget_collapse_title)"
                      +"});\">"+BloggerExtOptions.sidebar_widget_expan_title+"</a></span>";
            titleObj.prepend(link);
            titleObj.attr('id', widgetId+"_title");
            contentObj.hide();
            contentObj.attr('id', widgetId+"_content");
        }
    });

};
BloggerExt.register('sidebar_widget_expandable' ,  {
	sidebar_widget_expandable: true,
	sidebar_widget_expandable_version: 0.1,
	sidebar_widget_expandable_animate: false,
    sidebar_widget_expan_title: '[+]',
    sidebar_widget_collapse_title: '[-]',
    sidebar_widget_expandable_ids: []
});



// Register replace_smiley
BloggerExt.replace_smiley = function() {

    jQuery('div.blogbody').find('.main, .comments-body').each( function (i) {
            var newHtml = jQuery(this).html();
            for( var idx in BloggerExtOptions.smilies ) {
                newHtml = newHtml.replace(BloggerExtOptions.smilies[idx][0], BloggerExtOptions.smilies[idx][1]);
            }
            // fixed to no replace, if content is the same. and not eval script
            if(jQuery(this).html().length != newHtml.length) jQuery(this).attr("innerHTML", newHtml );

    });

};
BloggerExt.register('replace_smiley' ,  {
    replace_smiley: true,

    smilies: [
                [' :)', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :(', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/2.gif" style="border:0; margin:0; padding:0;" /> '],
                [' ;)', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :D', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/4.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :p', '<img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/10.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :$', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/32.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :-k', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/11.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :*', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/11.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :@', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/14.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :#', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/33.gif" style="border:0; margin:0; padding:0;" /> '],
                [' [-(', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/33.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :x', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/35.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :o', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/13.gif" style="border:0; margin:0; padding:0;" /> ']
             ]
});



// Register sidebar_widget_icon
BloggerExt.sidebar_widget_icon = function() {

    // find containers to expandable.
	for (var widgetTitle in BloggerExtOptions.sidebar_widget_icons) {
		var widgetImg = BloggerExtOptions.sidebar_widget_icons[widgetTitle];

        // find widget container with class name
        var sideObjs = BloggerExt.getSideObjByTitle(widgetTitle);
        if (sideObjs.length >=2 ) {
            var titleObj = sideObjs[0];
            titleObj.prepend(widgetImg);
        }
    }

};
BloggerExt.register('sidebar_widget_icon' ,  {
    sidebar_widget_icon: true,
    sidebar_widget_icons: {}
});



// Run All Register Process
BloggerExt.process();
}catch (e) { }

